package PlanData;

import static org.junit.Assert.assertTrue;

import java.util.ArrayList;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;

import po.PlanClassPO;
import po.PlanPO;

public class TestPlanData {

	PlanDataController pdc;
	
	@Before
	public void setUp(){
		pdc=new PlanDataController();
	}
	
	@Test
	public void testInsert(){
		PlanPO pp=new PlanPO();
		pp.department="2";
		PlanClassPO pcp=new PlanClassPO();
		pcp.department="2";
		pcp.lessonID="121201";
		pcp.grade="3";
		pcp.score="0";
		pp.list.add(pcp);
		assertTrue(pdc.Insert(pp));
	}
	
	@Test
	public void testUpdate(){
		PlanPO pp=new PlanPO();
		pp.department="2";
		PlanClassPO pcp=new PlanClassPO();
		pcp.department="2";
		pcp.lessonID="121201";
		pcp.grade="2";
		pcp.score="0";
		pp.list.add(pcp);
		assertTrue(pdc.Update(pp));
	}
	
	@Test
	public void testGet(){
		PlanPO pp=new PlanPO();
		
		pp=pdc.Get("2");
		Assert.assertEquals(pp.list.get(0).grade,"2");
	}
	
	@Test
	public void testGets(){
		ArrayList<PlanPO> pList=new ArrayList<PlanPO>();
		pList=pdc.Get();
		int size=pList.size();
		PlanPO pp=pList.get(size-1);
		Assert.assertEquals(pp.list.get(0).grade,"2");
	}
}
